home *** CD-ROM | disk | FTP | other *** search
- /* ASM2COM.C - John Hensley - September 1, 1986
-
- Converts DeSmet ASM88 files starting with INCLUDE "acom.inc"
- to .COM files.
- All code and data must be in "cseg".
- Must use bind's -A option.
- This allows writing the very smallest programs in ASM88.
-
-
- EXAMPLE
-
- -------------------------------------------------------------------------------
- ;NAME: TEST.A
- ;Example assembler source file with no C intialization, to be converted
- ;to a .com file.
-
- cseg
-
- INCLUDE "acom.inc"
-
- mov AH,09
- mov DX,&data
- int 21h
- int 20h
-
- data db 'This is a .com file.',13,'$'
-
- end
- -------------------------------------------------------------------------------
-
- ASM88 TEST
-
- BIND TEST -A
-
- ASM2COM TEST
-
- */
-
-
- #include "stdio.h"
-
- #define READ 00
-
- main(argc, argv)
-
- int argc;
- char *argv[];
-
- {
- int infile; /* Input file handle */
- int outfile; /* Output file handle */
- int count; /* Keeps count of bytes read */
- char rw_buffer[4096]; /* I/O buffer for read & write */
- char source[13]; /* Source file ascii name */
- char destination[13]; /* Destination file ascii name */
-
- if ( argc <= 1 )
- error( "Useage: ASM2COM file<.ext>\r\n"," " );
-
- file_names( argv[1], source, destination );
-
- if ( (infile = open( source, READ )) == ERR )
- error( "Can't open %s.", source );
-
- if ( fseek(infile, 0x300L, 0) == ERR )
- error( "ERROR setting input file pointer."," " );
-
- if ( (outfile = creat( destination )) == ERR )
- error( "Can't create new file %s.", destination );
-
- while((count = read( infile, rw_buffer, 4096 )) > 0)
- if ( write( outfile, rw_buffer, count ) == 0 )
- {
- fclose( outfile );
- unlink( destination );
- error( "ERROR writing to output file.", " " );
- }
-
- fclose(infile);
- fclose(outfile);
- unlink( source );
-
- }
-
-
- error( string, data ) /* Error handler */
-
- char *string, *data;
-
- {
- printf(string, data); /* Print the proper error message */
- exit(); /* Return to DOS */
- }
-
-
-
-
- file_names( argv, source, destination ) /* Creates a source and destination
- ascii file names. */
- char *argv, *source, *destination;
-
- {
- int i = 0;
- char letter;
-
- while( ( letter = toupper( *argv )) != '\0' && i < 8 && letter != '.' )
- {
- *(source++) = letter;
- *(destination++) = letter;
- i++;
- argv++;
- }
- *source = '\0';
- *destination = '\0';
- strcat( source, ".EXE" );
- strcat( destination, ".COM" );
-
- }
-
-